<template>
	<div>
		<header class="navigation">
			<div @click="retreat"><img src="../assets/rightbut.png"></div>
			<div>个人资料</div>
			<div></div>
		</header>
		<div class="content">
			<input type="text" placeholder="请输入名称" ref='username'/>
		</div>
		<div class="preserve" @click="preserve">保存</div>
	</div>
</template>

<script>
	import { BaseUrl } from '../Baseurl/common.js';
	export default{
		data(){
			return{
				token:''
			}
		},
		created(){
			this.token = localStorage.getItem('token');
		},
		methods:{
			//导航退后
			retreat:function(){
				window.history.go(-1);
			},
			preserve:function(){
				var username = this.$refs.username.value;
				if(username !=''){
					var url = BaseUrl + 'users/manageuserNickname?appId=wap&' + 'token=' + this.token + '&userNickname=' + username;
					this.$http.get(url).then(res=>{
//						console.log(res.data);
						if(res.data.code == '10000'){
							this.$router.push({
								path:'/personal'
							})
						}
					})
				}
				
			}
		}
	}
</script>

<style scoped="scoped">
	.navigation{
		height: 1rem;
		background: #fff;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 0.24rem;
		color: #323232;
		font-size: 0.36rem;
	}
	
	.navigation img{
		width: 0.2rem;
		height: 0.36rem;
		display: block;
	}
	.content{
		padding: 0 0.25rem;
	}
	.content input{
		width: 100%;
		border: none;
		outline: none;
		border-bottom: 1px solid #ccc;
	}
	.preserve{
		padding: 0.2rem 0;
		margin: 0 0.25rem;
		border-radius: 0.5rem;
		text-align: center;
		background: #ff2040;
		font-size: 0.26rem;
		color: #FFF;
		margin-top: 0.5rem;
	}
</style>